package javaParser;


import com.hp.hpl.jena.ontology.*;
import com.hp.hpl.jena.rdf.model.ModelFactory;

public class SourceOntology {
	 // data members
	 
	 private OntModel sourceOntModel;  
	 public final String ontologyURI;
	 
	 /// Constructor. If you want to use the default URI, pass an empty string ("")
	 public SourceOntology(String __ontologyURI)
	 {
	   ontologyURI = (__ontologyURI.length() > 0 ? __ontologyURI :
		   //we're using the DM's source ontology, you can't define sourcefile from DataEntry
		   //when nothing like that exists.
	     //"http://cseg670project.googlecode.com/svn/trunk/DataEntry_Official/sourcefile" );      
	       "http://cseg670project.googlecode.com/svn/trunk/ontologies/source.owl" );  
	   sourceOntModel = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM, null );
	 }
	 
	 public boolean Initialize()
	  {    
	    try{
	      sourceOntModel.read(ontologyURI);
	    }    
	    catch(Exception e)
	    {
	      System.err.print("Could not retrieve ontology from source: " + ontologyURI + "; reason: " +
	        e.getMessage() + "\n");
	      return false;
	    }
	    
	    return true;        
	  }
	     
	 
	 public OntClass oClass()
	 {
	   OntClass t = sourceOntModel.getOntClass(ontologyURI + "#Class");
	   assert(t != null);
	   return(t);    
	 }
	 
	 public OntClass oMethod()
	 {
	   OntClass t = sourceOntModel.getOntClass(ontologyURI + "#Method");
	   assert(t != null);
	   return(t);    
	 }
	 
	 public OntProperty oCalls()
	 {
	   OntProperty t = sourceOntModel.getOntProperty(ontologyURI + "#calls");
	   assert(t != null);
	   return(t);
	 }
	 
	 public OntProperty oNamed()
	 {
	    OntProperty t = sourceOntModel.getOntProperty(ontologyURI + "#named");
	    assert(t != null);
	    return(t);
	 }
	 
	 public OntProperty oHasMethod() {
		 OntProperty t = sourceOntModel.getOntProperty(ontologyURI + "#hasMethod");
		 assert(t!=null);
		 return(t);
	 }
	 
	}
